//
//  FirstModel.m
//  取数据
//
//  Created by dllo on 15/11/10.
//  Copyright (c) 2015年 JEH. All rights reserved.
//

#import "FirstModel.h"

@implementation FirstModel

- (instancetype)initWithDataSource:(NSDictionary *)data
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:data];
    }
    return self;
}

-(id)valueForUndefinedKey:(NSString *)key {
    return nil;
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"data"]) {
        NSArray *array = value;
        NSMutableArray *mutable = [[NSMutableArray alloc] initWithCapacity:0];
        for (NSDictionary *dic in array) {
            SecondModel *second = [[SecondModel alloc] initWithDataSource:dic];
            [mutable addObject:second];
//            NSLog(@"%@", second.title);
        }
        self.datas = [[NSArray alloc] initWithArray:mutable];
//        NSLog(@"%@", _datas);
    }
}



@end
